Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seed order to manage logs overflow #10485

Merged
merged 24 commits into from
Sep 6, 2023
Merged

Conversation

amirylm
Copy link
Collaborator

@amirylm amirylm commented Sep 5, 2023

Using deterministic seed ordering to drop the same logs across the network in cases of logs overflow, where we hit the limits:

  • buffer.enqueue() - ensures that buffer size won't exceed limits, while dropping the same logs across the network
  • provider.GetLatestPayloads() - ensures that in cases of multiple results, the same set of logs are used across the network
  • recoverer.GetRecoveryProposals() - same as latest payloads

@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2023

I see that you haven't updated any CHANGELOG files. Would it make sense to do so?

@amirylm amirylm changed the base branch from develop to bump-ocr2keepers September 5, 2023 11:43
@amirylm amirylm marked this pull request as ready for review September 5, 2023 11:43
@amirylm amirylm requested a review from a team as a code owner September 5, 2023 11:43
@amirylm amirylm requested a review from infiloop2 September 5, 2023 11:46
@@ -596,3 +604,18 @@ func (r *logRecoverer) removePending(workID string) {
}
r.pending = updated
}

// sortPending sorts the pending list by a random order based on the latest block.
Copy link
Contributor

@infiloop2 infiloop2 Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be different order on nodes as latestBlock will be out of sync. We don't really need consensus in recoverables so it should be ok here, but in provider we can use latestBlock % 100 or something similar to ensure it stays same across nodes for some time

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used latestBlock / 10, do you think we need 100? (maybe for fast chains)

@amirylm amirylm force-pushed the seed-order-to-manage-overflow branch from 303ff94 to 7007c6e Compare September 5, 2023 12:48
Comment on lines 122 to 124
sort.Slice(b.logs, func(i, j int) bool {
return shuffledLogIDs[i] < shuffledLogIDs[j]
})
Copy link
Contributor

@infiloop2 infiloop2 Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just want to verify this will work properly if the indices passed in comparator doesn't refer to the slice being sorted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the comparator accepts indices and returns a bool, making it completely decoupled from the underlying slice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually digging more it's giving me some unexpected behaviour in playground. Will followup offline

// Divided by 10 to ensure that nodes with similar block numbers won't end up with different order.
// NOTE: the lock must be held before calling this function.
func (r *logRecoverer) sortPending(latestBlock uint64) {
normalized := latestBlock / 10
Copy link
Contributor

@infiloop2 infiloop2 Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. 10 might not be enough on fast chains like arb. 100 might be better (but then its slow on other chains also ) so not sure

Copy link
Collaborator Author

@amirylm amirylm Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know the block time within the recoverer, we could also compute something based on the block time.
e.g. 100 / blockTimeSeconds

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that can have further issues when blockTime is not synchronized 😅

infiloop2
infiloop2 previously approved these changes Sep 5, 2023
Copy link
Contributor

@infiloop2 infiloop2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good! just couple of non blocking nits

@infiloop2 infiloop2 self-requested a review September 6, 2023 15:57
Base automatically changed from bump-ocr2keepers to develop September 6, 2023 16:04
@infiloop2 infiloop2 dismissed their stale review September 6, 2023 16:04

The base branch was changed.

@amirylm amirylm requested a review from a team as a code owner September 6, 2023 16:04
shuffledLogIDs := make(map[string]string, len(b.logs))
for _, log := range b.logs {
logID := log.getLogID()
shuffledLogIDs[logID] = random.ShuffleString(logID, randSeed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. i think this will always be constant for a given log, so we can also make it a part of logID itself

@infiloop2 infiloop2 enabled auto-merge September 6, 2023 17:28
@infiloop2 infiloop2 added this pull request to the merge queue Sep 6, 2023
@cl-sonarqube-production
Copy link

Merged via the queue into develop with commit ad22c6e Sep 6, 2023
@infiloop2 infiloop2 deleted the seed-order-to-manage-overflow branch September 6, 2023 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants